 export let base='http://www.localhost:3000'
 
let post={
	method:'POST',
	header:{"Content-Type":"application/x-www-form-urlencoded"	}
}

//主页数据接口
export let homeList=async function(){
	let url=base+'/cha'
	uni.showLoading({
      title:"加载中"		
	})
	let result=await uni.request({
		url,	
	})
	uni.hideLoading()
	return result[1].data
}
//商品列表加载
export let productlist=async function(pno=1,fid=2){
	uni.showLoading({
		title:'加载中'
	})
	let url=base + '/piao_fy'
	 let result=await uni.request({
		url,
		data:{fid,pno}
	})
	uni.hideLoading()
	return result[1].data
}

//商品id对应详情
export let productdetails=async function(lid=1){
	uni.showLoading({
		title:'加载中'
	})
	let url=base + '/detail'
	 let result=await uni.request({
		url,
		data:{lid}
	})
	uni.hideLoading()
	return result[1].data
}

//商品类别对应详情
export let productcategory=async function(lid=1){
	uni.showLoading({
		title:'加载中'
	})
	let url=base + '/piao'
	 let result=await uni.request({
		url,
		data:{lid}
	})
	uni.hideLoading()
	return result[1].data
}
//用户注册
export let userRegister=async function(username,nickname,upwd,email,phone){
	let url=base + '/register'
	uni.showLoading({
		title:'注册中'
	})
	let result=await uni.request({
		url,
	...post,
	data:{username,nickname,upwd,email,phone}
	})
	uni.hideLoading()
	return result[1].data	
}
//用户登录
export let userLogin=async function(phone,upwd){
	let url=base + '/login'
	uni.showLoading({
		title:'注册中'
	})
	let result=await uni.request({
		url,
	...post,
	data:{phone,upwd}
	})
	uni.hideLoading()
	return result[1].data	
}

//搜索查询接口
export let productSearch=async function(pno,dd){
	uni.showLoading({
		title:'加载中'
	})
	let url=base + '/sousuo'
	 let result=await uni.request({
		url,
		data:{pno,dd}
	})
	uni.hideLoading()
	return result[1].data
}
//当前用户默认收货地址查询
export let shopAdress=async function(uid){
	uni.showLoading({
		title:'加载中'
	})
	let url=base + '/shouhuocha'
	 let result=await uni.request({
		url,
		data:{uid}
	})
	uni.hideLoading()
	return result[1].data
}
//订单添加
export let orderadd=async function(uid,lid,user_address,status,order_time,pay_time,deliver_time,received, title,price,pic,num,category,freight,paylei,emailname,tel){
	let url=base + '/Addzz'
	uni.showLoading({
		title:'注册中'
	})
	let result=await uni.request({
		url,
	...post,
	data:{uid,lid,user_address,status,order_time,pay_time,deliver_time,received, title,price,pic,num,category,freight,paylei,emailname,tel}
	})
	uni.hideLoading()
	return result[1].data	
}

//足迹添加
export let addfooter=async function(uid,lidd,title,price,pic){
	let url=base + '/addfooter'
	uni.showLoading({
		title:'注册中'
	})
	let result=await uni.request({
		url,
	...post,
	data:{uid,lidd,title,price,pic}
	})
	uni.hideLoading()
	return result[1].data	
}
//足迹查询
export let footercha=async function(uid){
	uni.showLoading({
		title:'加载中'
	})
	let url=base + '/zjcha'
	 let result=await uni.request({
		url,
		data:{uid}
	})
	uni.hideLoading()
	return result[1].data
}


//收藏添加
export let addcollect=async function(uid,lidd,title,price,pic){
	let url=base + '/Addcollect'
	uni.showLoading({
		title:'注册中'
	})
	let result=await uni.request({
		url,
	...post,
	data:{uid,lidd,title,price,pic}
	})
	uni.hideLoading()
	return result[1].data	
}
//购物车添加
export let Addmallcart=async function(uid,lidd,title,price,pic,num){
	let url=base + '/Addmallcart'
	uni.showLoading({
		title:'注册中'
	})
	let result=await uni.request({
		url,
	...post,
	data:{uid,lidd,title,price,pic,num}
	})
	uni.hideLoading()
	return result[1].data	
}
//购物车查询
export let Addmallcartchas=async function(uid){
	let url=base + '/Addmallcartcha'
	uni.showLoading({
		title:'注册中'
	})
	let result=await uni.request({
		url,
	data:{uid}
	})
	uni.hideLoading()
	return result[1].data	
}

//订单详情
export let oredercha=async function(uid,status){
	uni.showLoading({
		title:'加载中'
	})
	let url=base + '/ddCha'
	 let result=await uni.request({
		url,
		data:{uid,status}
	})
	uni.hideLoading()
	return result[1].data
}

//订单详情
export let orederxqcha=async function(uid,oid){
	uni.showLoading({
		title:'加载中'
	})
	let url=base + '/ddxqCha'
	 let result=await uni.request({
		url,
		data:{uid,oid}
	})
	uni.hideLoading()
	return result[1].data
}
//收藏查询
export let sccha=async function(uid){
	uni.showLoading({
		title:'加载中'
	})
	let url=base + '/sccha'
	 let result=await uni.request({
		url,
		data:{uid}
	})
	uni.hideLoading()
	return result[1].data
}

//订单删除接口
export let orderdelete=async function(oid){
	uni.showLoading({
		title:'加载中'
	})
	let url=base + '/dd_sc'
	 let result=await uni.request({
		url,
		data:{oid}
	})
	uni.hideLoading()
	return result[1].data
}

//收藏删除接口
export let scdelete=async function(lid){
	uni.showLoading({
		title:'加载中'
	})
	let url=base + '/scc_sc'
	 let result=await uni.request({
		url,
		data:{lid}
	})
	uni.hideLoading()
	return result[1].data
}


//确认收货
export let querensh=async function(uid,oid){
	uni.showLoading({
		title:'加载中'
	})
	let url=base + '/tytk'
	let result=await uni.request({
		url,
		...post,
		data:{oid,uid}
	})
	uni.hideLoading()
	return result[1].data
}

//确认收货
export let speedfh=async function(uid,oid){
	uni.showLoading({
		title:'加载中'
	})
	let url=base + '/speedfh'
	let result=await uni.request({
		url,
		...post,
		data:{oid,uid}
	})
	uni.hideLoading()
	return result[1].data
}
//查询收货地址是否存在以及pid
export let shczcha=async function(uid){
	uni.showLoading({
		title:'加载中'
	})
	let url=base + '/shczcha'
	 let result=await uni.request({
		url,
		data:{uid}
	})
	uni.hideLoading()
	return result[1].data
}
//收货地址添加接口
export let ssdztj=async function(uid,address,name,tel,province,county,diqutel,pid,tell){
	uni.showLoading({
		title:'加载中'
	})
	let url=base + '/ssdztj'
	let result=await uni.request({
		url,
		...post,
		data:{uid,address,name,tel,province,county,diqutel,pid,tell}
	})
	uni.hideLoading()
	return result[1].data
}

//收货地址添加接口2
export let ssdztj2=async function(uid,address,name,tel,province,county,diqutel,pid,tell){
	uni.showLoading({
		title:'加载中'
	})
	let url=base + '/ssdztj2'
	let result=await uni.request({
		url,
		...post,
		data:{uid,address,name,tel,province,county,diqutel,pid,tell}
	})
	uni.hideLoading()
	return result[1].data
}

//查询所有uid收货地址
export let shouhuocha=async function(uid){
	uni.showLoading({
		title:'加载中'
	})
	let url=base + '/chaAddress'
	 let result=await uni.request({
		url,
		data:{uid}
	})
	uni.hideLoading()
	return result[1].data
}
//订单地址查询
export let xhaAddress=async function(uid,id){
	uni.showLoading({
		title:'加载中'
	})
	let url=base + '/xhaAddress'
	 let result=await uni.request({
		url,
		data:{uid,id}
	})
	uni.hideLoading()
	return result[1].data
}